package com.sidianzhong.sdz.controller;

import com.sidianzhong.sdz.model.*;
import com.sidianzhong.sdz.service.*;
import com.sidianzhong.sdz.utils.PageInfo;
import com.sidianzhong.sdz.utils.ResultModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by hxg on 2016/10/06.
 */
@Api(description = "巡机记录数据表")
@Controller
public class WebInspectiondatarecordController {

    @Autowired
    WebInspectiondatarecordService webInspectiondatarecordService;

    @Autowired
    WebInspectionrecordService webInspectionrecordService;

    @Autowired
    HttpServletResponse response;
    @ApiOperation(value = "查询巡机记录")
    @RequestMapping(value = "/getWebInspectiondatarecords",
                    method = { RequestMethod.GET },
                    produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getWebInspectiondatarecords(
            HttpServletRequest request,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "sortItem", required = false, defaultValue = "id") String sortItem,
            @RequestParam(value = "sortOrder", required = false, defaultValue = "desc") String sortOrder,
            @RequestParam(value = "recordid", required = false) Integer recordid,
            @RequestParam(value = "equipmenttypekey", required = false) String equipmenttypekey,
            @RequestParam(value = "equipmentkey", required = false) String equipmentkey
    ) {
        WebInspectiondatarecord item = new WebInspectiondatarecord();
        if( recordid != null ){
            item.setRecordid(recordid);
        }
        if( equipmenttypekey != null ){
            item.setEquipmenttypekey(equipmenttypekey);
        }
        if( equipmentkey != null ){
            item.setEquipmentkey(equipmentkey);
        }
       PageInfo<WebInspectiondatarecord> list =  webInspectiondatarecordService.getListWithPaging(pageNum, pageSize, sortItem, sortOrder,item);
       return new ResponseEntity<>(ResultModel.ok(list), HttpStatus.OK);
    }





}
